package com.example.mapper;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.example.pojo.oilListPojo;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * ClassName:oilListMapp
 * Package:com.example.mapper
 * Description:
 *
 * @Author：牧星苑
 * @Create 2025/9/23 17:35
 * @Version 1.0
 */
@Mapper
public interface oilListMapp {
    //插入一行油液基本信息
    @DS("newMscLowCodeFormal")
    @Insert("insert into ddm_oil_basic_information (" +
            "id, create_time, update_time, " +
            "creator, process_status, sys_update_user, " +
            "sys_audit_user, sys_audit_time, sys_deleted, " +
            "workshop, line, op, " +
            "model, equipment_name_chinese, equipment_name_english, " +
            "equipment_name_russian, oil_name_chinese, oil_name_english, " +
            "oil_name_russian, specification, refractive_index, " +
            "project, requirement, standard_value, " +
            "inspection_frequency, upper_limit, lower_limit) " +
            "VALUES (" +
            "#{id}, #{create_time}, #{update_time}, " +
            "#{creator}, #{process_status}, #{sys_update_user}, " +
            "#{sys_audit_user}, #{sys_audit_time}, #{sys_deleted}, " +
            "#{workshop}, #{line}, #{op}, " +
            "#{model}, #{equipment_name_chinese}, #{equipment_name_english}, " +
            "#{equipment_name_russian}, #{oil_name_chinese}, #{oil_name_english}, " +
            "#{oil_name_russian}, #{specification}, #{refractive_index}, " +
            "#{project}, #{requirement}, #{standard_value}, " +
            "#{inspection_frequency}, #{upper_limit}, #{lower_limit})")
    void insertOne(oilListPojo pojo);

    //修改一行油液基本信息
    @DS("newMscLowCodeFormal")
    @Update("update ddm_oil_basic_information " +
            "set " +
            "update_time=#{update_time}, " +
            "creator=#{creator}, " +
            "process_status=#{process_status}, " +
            "sys_update_user=#{sys_update_user}, "+
            "sys_audit_user=#{sys_audit_user}, " +
            "sys_audit_time=#{sys_audit_time}, " +
            "sys_deleted=#{sys_deleted}, " +
            "workshop=#{workshop}, " +
            "line=#{line}, " +
            "op=#{op}, " +
            "model=#{model}, "+
            "equipment_name_chinese=#{equipment_name_chinese}," +
            "equipment_name_english=#{equipment_name_english}, "+
            "equipment_name_russian=#{equipment_name_russian}, " +
            "oil_name_chinese=#{oil_name_chinese}, " +
            "oil_name_english=#{oil_name_english}, " +
            "oil_name_russian=#{oil_name_russian}, " +
            "specification=#{specification}, " +
            "refractive_index=#{refractive_index}," +
            "project=#{project}, " +
            "requirement=#{requirement}, "+
            "standard_value=#{standard_value}, " +
            "inspection_frequency=#{inspection_frequency}, " +
            "upper_limit=#{upper_limit}, " +
            "lower_limit=#{lower_limit} " +
            "where id=#{id}")
    void editOneById(oilListPojo pojo);

    //查询所有的油液基本信息
    @DS("newMscLowCodeFormal")
    @Select("select * from ddm_oil_basic_information where sys_deleted=0 order by line, op")
    List<oilListPojo> queryAll();

    //查询某三个字段为某值的数据
    @DS("newMscLowCodeFormal")
    @Select("select * from ddm_oil_basic_information " +
            "where sys_deleted=0 and ${fieldName1}=#{fieldValue1} and ${fieldName2}=#{fieldValue2} and ${fieldName3}=#{fieldValue3}")
    List<oilListPojo> queryThreeFields(String fieldName1, String fieldValue1, String fieldName2, String fieldValue2, String fieldName3, String fieldValue3);
}
